<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{number}}.{{title}}</title>
    <!-- <link href="//unpkg.com/layui@2.9.9/dist/css/layui.css" rel="stylesheet"> -->

    <script src="../static/layui/layui.js"></script>
    <link href="../static/layui/css/layui.css" rel="stylesheet">
    <link href="//unpkg.com/layui@2.9.10/dist/css/layui.css" rel="stylesheet">

    <!-- 引入 ACE 在线编辑器 -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js" type="text/javascript"
        charset="utf-8"></script>
    <!-- 引入 ACE 的语言工具,自动补齐等功能 -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ext-language_tools.js" type="text/javascript"
        charset="utf-8"></script>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script src="../static/js/jquery-3.7.1.min.js" type="text/javascript" charset="utf-8"></script>
    <!-- <script src="http://192.168.42.197:8880/home/ryan/Linux_code/Online_Judge/oj_server/template_html/js/jquery-3.7.1.min.js" type="text/javascript" charset="utf-8"></script> -->
    <!--   <script src="./js/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="./js/ext-language_tools.js" type="text/javascript" charset="utf-8"></script> -->
    <script src="../static/assets/js/color-modes.js"></script>
    <!-- <link rel="canonical" href="https://getbootstrap.com/docs/5.3/examples/headers/">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"> -->
    <link href="../static/assets/dist/css/bootstrap.min.css" rel="stylesheet">

    <style>
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }

        .b-example-divider {
            width: 100%;
            height: 3rem;
            background-color: rgba(245, 8, 8, 0.936);
            border: solid rgba(13, 144, 226, 0.15);
            border-width: 1px 0;
            box-shadow: inset 0 .5em 1.5em rgba(5, 233, 187, 0.1), inset 0 .125em .5em rgba(13, 238, 238, 0.15);
        }

        .b-example-vr {
            flex-shrink: 0;
            width: 1.5rem;
            height: 100vh;
        }

        .bi {
            vertical-align: -.125em;
            fill: currentColor;
        }

        .nav-scroller {
            position: relative;
            z-index: 2;
            height: 2.75rem;
            overflow-y: hidden;
        }

        .nav-scroller .nav {
            display: flex;
            flex-wrap: nowrap;
            padding-bottom: 1rem;
            margin-top: -1px;
            overflow-x: auto;
            text-align: center;
            white-space: nowrap;
            -webkit-overflow-scrolling: touch;
        }

        .btn-bd-primary {
            --bd-violet-bg: #712cf9;
            --bd-violet-rgb: 112.520718, 44.062154, 249.437846;

            --bs-btn-font-weight: 600;
            --bs-btn-color: var(--bs-white);
            --bs-btn-bg: var(--bd-violet-bg);
            --bs-btn-border-color: var(--bd-violet-bg);
            --bs-btn-hover-color: var(--bs-white);
            --bs-btn-hover-bg: #6528e0;
            --bs-btn-hover-border-color: #6528e0;
            --bs-btn-focus-shadow-rgb: var(--bd-violet-rgb);
            --bs-btn-active-color: var(--bs-btn-hover-color);
            --bs-btn-active-bg: #5a23c8;
            --bs-btn-active-border-color: #5a23c8;
        }

        .bd-mode-toggle {
            z-index: 1500;
        }

        .bd-mode-toggle .dropdown-menu .active .bi {
            display: block !important;
        }
    </style>
    <style>
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }

        .b-example-divider {
            width: 100%;
            height: 3rem;
            background-color: rgba(0, 0, 0, .1);
            border: solid rgba(0, 0, 0, .15);
            border-width: 1px 0;
            box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
        }

        .b-example-vr {
            flex-shrink: 0;
            width: 1.5rem;
            height: 100vh;
        }

        .bi {
            vertical-align: -.125em;
            fill: currentColor;
        }

        .nav-scroller {
            position: relative;
            z-index: 2;
            height: 2.75rem;
            overflow-y: hidden;
        }

        .nav-scroller .nav {
            display: flex;
            flex-wrap: nowrap;
            padding-bottom: 1rem;
            margin-top: -1px;
            overflow-x: auto;
            text-align: center;
            white-space: nowrap;
            -webkit-overflow-scrolling: touch;
        }

        .btn-bd-primary {
            --bd-violet-bg: #712cf9;
            --bd-violet-rgb: 112.520718, 44.062154, 249.437846;

            --bs-btn-font-weight: 600;
            --bs-btn-color: var(--bs-white);
            --bs-btn-bg: var(--bd-violet-bg);
            --bs-btn-border-color: var(--bd-violet-bg);
            --bs-btn-hover-color: var(--bs-white);
            --bs-btn-hover-bg: #6528e0;
            --bs-btn-hover-border-color: #6528e0;
            --bs-btn-focus-shadow-rgb: var(--bd-violet-rgb);
            --bs-btn-active-color: var(--bs-btn-hover-color);
            --bs-btn-active-bg: #5a23c8;
            --bs-btn-active-border-color: #5a23c8;
        }

        .bd-mode-toggle {
            z-index: 1500;
        }

        .bd-mode-toggle .dropdown-menu .active .bi {
            display: block !important;
        }
    </style>


    <link href="../static/css/headers.css" rel="stylesheet">
    <link href="../static/css/sidebars.css" rel="stylesheet">

    <style>
        * {
            margin: 0;
            padding: 0;
            /* 默认存在的 */
        }

        html,
        body {
            /* 默认存在的 */
            width: 100%;
            height: 100%;
        }

        div .ace_editor {
            /* div 标签下的 ace_editor */
            height: 600px;
            width: 100%;
        }

        .container .part1 {
            width: 100%;
            height: 100%;
        }

        .container .part1 .left_desc {
            width: auto;
            float: left;
            /* text-align: center; */
            /* 左浮动 */
        }

        /* .container .part1 .right_code {
            width: 30%;
            float: right;
           
        } */

        .container .part2 {
            width: 100%;
            /* 提交代码 按钮 */

        }

        /* .container .part2 {
            width: 100%; 
             float: left;
        } */

        .container .part2 .button .bt {
            width: 40%;
            height: 30px;
            font-size: large;
            float: right;
        }

        .btn2 {
            /* Login */
            display: inline-block;
            background-color: #333;
            color: #fff;
            text-decoration: none;
        }


        .desc {
            width: 500px;
            height: 200px;

        }

        .box0 {
            width: 560px;
            height: 80px;
            background-color: rgb(228, 199, 228);
            overflow: hidden;
            /* 不允许跨行 */
            white-space: nowrap;
        }

        .box1 {
            width: 300px;
            height: 50px;
            background-color: rgb(225, 203, 156);
            display: inline-block;
            /* display: inline; */
            /* float: left; */
        }

        .box2 {
            width: 100px;
            height: 50px;
            background-color: rgb(142, 192, 159);
            display: inline-block;
            /* display: inline; */
        }

        .box3 {
            width: 200px;
            height: 50px;
            background-color: rgb(233, 152, 215);
            display: inline-block;
            /* display: inline; */
        }

        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }

        .b-example-divider {
            width: 100%;
            height: 3rem;
            background-color: rgba(0, 0, 0, .1);
            border: solid rgba(0, 0, 0, .15);
            border-width: 1px 0;
            box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
        }

        .b-example-vr {
            flex-shrink: 0;
            width: 1.5rem;
            height: 100vh;
        }

        .bi {
            vertical-align: -.125em;
            fill: currentColor;
        }

        .nav-scroller {
            position: relative;
            z-index: 2;
            height: 2.75rem;
            overflow-y: hidden;
        }

        .nav-scroller .nav {
            display: flex;
            flex-wrap: nowrap;
            padding-bottom: 1rem;
            margin-top: -1px;
            overflow-x: auto;
            text-align: center;
            white-space: nowrap;
            -webkit-overflow-scrolling: touch;
        }

        .btn-bd-primary {
            --bd-violet-bg: #712cf9;
            --bd-violet-rgb: 112.520718, 44.062154, 249.437846;

            --bs-btn-font-weight: 600;
            --bs-btn-color: var(--bs-white);
            --bs-btn-bg: var(--bd-violet-bg);
            --bs-btn-border-color: var(--bd-violet-bg);
            --bs-btn-hover-color: var(--bs-white);
            --bs-btn-hover-bg: #6528e0;
            --bs-btn-hover-border-color: #6528e0;
            --bs-btn-focus-shadow-rgb: var(--bd-violet-rgb);
            --bs-btn-active-color: var(--bs-btn-hover-color);
            --bs-btn-active-bg: #5a23c8;
            --bs-btn-active-border-color: #5a23c8;
        }

        .bd-mode-toggle {
            z-index: 1500;
        }

        .bd-mode-toggle .dropdown-menu .active .bi {
            display: block !important;
        }
    </style>

    <script>
        $('body').css({

            "overflow": "hidden"

        });
    </script>
</head>

<body>


    <div style="height: 10px;"></div>
    <div class="id1">
        <blockquote class="id2 layui-elem-quote layui-text" style="margin: 0px;">
            <span id="number" class="span1" style="font-size: 25px;"><span id="num">{{number}}</span>.{{title}}</span>
        </blockquote>

        <div class="layui-card layui-panel">
            <div class="layui-card-header">
            </div>
            <div class="layui-card-body">

                <div class="d-grid gap-3" style="grid-template-columns: 1fr 2fr;">
                    <div class="bg-body-tertiary border rounded-3">

                        <!-- 题目基本信息 -->
                        <div class="layui-bg-gray" style="padding: 10px; width: 691px; ">
                            <div class="layui-row layui-col-space15">
                                <div class="layui-col-md6">

                                    <div class="layui-card" style="padding: 10px; width: 670px">

                                        <div class="layui-card-header ">
                                            <h3><b>题目描述</b></h3>
                                            <!-- <div style="width: 50% ;float: left;">
                                                <h3>难度{{star}}</h3>
                                            </div>
                                            <div id="ID-rate-demo-readonly"
                                                style="width: 50%;float: left; margin: 0% ;padding:0%">                        
                                            </div> -->
                                        </div>
                                        <div class="layui-card-body">
                                            <br>
                                            <p>{{desc}}</p>
                                            <hr>
                                        </div>

                                    </div>

                                    <div class="layui-card" style="padding: 10px; width: 670px">
                                        <div class="layui-card-header ">
                                            <h3><b>数据范围</b></h3>
                                        </div>

                                        <div class="layui-card-body">
                                            
                                                <p>{{data_range}}</p>
                                                <hr>
                                            
                                        </div>

                                    </div>

                                    <div class="result1 layui-card" style="padding: 10px; width: 670px">
                                        <div class="layui-card-header ">
                                            <h3><b>运行结果</b></h3>
                                            
                                        </div>

                                        <div class="layui-card-body">
                                            <div class="result">

                                                <hr>
                                              
                                            </div>
                                        </div>

                                    </div>
                                    
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="border rounded-3" style="background-color: #1e1e1e;">

                        <!-- 代码编辑区 -->
                        <div class="right_code">
                            <!-- pre 标签可以保持代码原貌 -->
                            <pre id="code"
                                class="ace_editor"><textarea class="ace_textinput" style="height: max-content;">{{pre_code}}</textarea></pre>
                        </div>




                    </div>
                </div>

            </div>

        </div>
        
        <blockquote class="id2 layui-elem-quote layui-text" style="height: 72px;">
            <div class="part2">
                
                <!-- <div class="result"></div> -->

                <div class="button" style="float: right;">
                    <button type="button" class="bt layui-btn layui-btn-normal layui-btn-radius" lay-on="test-msg-dark" 
                        onclick="submit()">提交代码</button>
                </div>

                

            </div>
        </blockquote>

    </div>








    <!-- <div class="container">
        <div class="navbar"></div>

        <div class="part1">

            <div class="left_desc">
                <h4> <span id="number">{{number}}</span>.{{title}}.{{star}}</h4>
                <p>{{desc}}</p>
            </div>
              <div class="right_code">
               
                <pre id="code" class="ace_editor"><textarea class="ace_textinput">{{pre_code}}</textarea></pre>
            </div>
        </div>

        <div class="part2">

            <div class="result"></div>
            <div class="button"><button class="bt" onclick="submit()">提交代码</button></div>
        </div>


    </div> -->


    <script>
        layui.use(function(){
          var layer = layui.layer;
          var util = layui.util;
          // 事件
          util.on('lay-on', {
            
            "test-msg-dark": function(){
              layer.msg('提交成功');
            },
            
          })
        });
        </script>


    <!-- ACE 辅助函数 -->
    <script>
        //初始化对象
        editor = ace.edit("code");
        //设置风格和语言（更多风格和语言，请到github上相应目录查看）
        // 主题大全：http://www.manongjc.com/detail/25-cfpdrwkkivkikmk.html
        editor.setTheme("ace/theme/clouds_midnight");
        editor.session.setMode("ace/mode/c_cpp");
        // 字体大小
        editor.setFontSize(16);
        // 设置默认制表符的大小:
        editor.getSession().setTabSize(4);
        // 设置只读（true时只读，用于展示代码）
        editor.setReadOnly(false);
        // 启用提示菜单
        ace.require("ace/ext/language_tools");
        editor.setOptions({
            enableBasicAutocompletion: true,
            enableSnippets: true,
            enableLiveAutocompletion: true
        });

        layui.use(function () {
            var rate = layui.rate;
            // 渲染
            rate.render({
                elem: '#ID-rate-demo-readonly',
                value: 3,
                readonly: true
            });
        });



        function submit() {
            // 提交按钮的编写
            // alert("hello http!");
            console.log("hello http!");

            var code = editor.getSession().getValue();
            console.log(code);

            // 获取指定题号    . 类选择器                      # id 选择器
            var number = $(".id1 .id2 #number #num").text();
            console.log(number);
            console.log("number: " + number);

            var judge_url = "/judge/" + number;

            $.ajax({
                method: 'Post',   // 向后端发起请求的方式
                url: judge_url,   // 向后端指定的url发起请求
                dataType: 'json', // 告诉 server, 需要的格式
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify({
                    'code': code,
                    'input': ''
                }),
                success: function (data) {
                    // 成功得到结果
                    //console.log(data);
                    show_result(data);
                }
            });

            function show_result(data) {
                console.log(data.status);
                console.log(data.reason);
                // console.log("KKKK");

                // 拿到结果标签
                var result_div = $(".id1 .layui-card .layui-card-body .d-grid .bg-body-tertiary .layui-bg-gray .layui-row .layui-col-md6 .result1 .layui-card-body .result");

                // .id1 .layui-card .layui-card-body .d-grid .bg-body-tertiary .layui-bg-gray .layui-row .layui-col-md6 .result1 .layui-card-body .result
                result_div.empty();  // 每次清理结果

                // 首先拿到结果的状态码和原因结果
                var _status = data.status;
                var _reason = data.reason;

                var reason_lable = $("<p>", {
                    text: _reason
                });
                reason_lable.appendTo(result_div);

                if (_status == 0) {

                    // 请求是成功的,编译运行没有问题
                    var _stdout = data.stdout;
                    var _stderr = data.stderr;

                    // var reason_lable = $( "<p>",{
                    //     text:reason
                    // });

                    var stdout_lable = $("<pre>", {
                        text: _stdout
                    });
                    var stderr_lable = $("<pre>", {
                        text: _stderr
                    });

                    stdout_lable.appendTo(result_div);
                    stderr_lable.appendTo(result_div);

                }
                else {
                    // 编译运行出错

                    // 手动创建标签
                    // var reason_lable = $( "<p>",{
                    //     text:reason
                    // });

                    // 将手动创建的reason_div 插入到 result_div 中
                    // reason_lable.appendTo(result_div);
                }

            }


        }
    </script>

    <script src="//cdn.staticfile.org/layui/2.9.10/layui.js"></script>
    <script>
        //JS 
        layui.use(['element', 'layer', 'util'], function () {
            var element = layui.element;
            var layer = layui.layer;
            var util = layui.util;
            var $ = layui.$;

            //头部事件
            util.event('lay-header-event', {
                menuLeft: function (othis) { // 左侧菜单事件
                    layer.msg('展开左侧菜单的操作', { icon: 0 });
                },
                menuRight: function () {  // 右侧菜单事件
                    layer.open({
                        type: 1,
                        title: '更多',
                        content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                        area: ['260px', '100%'],
                        offset: 'rt', // 右上角
                        anim: 'slideLeft', // 从右侧抽屉滑出
                        shadeClose: true,
                        scrollbar: false
                    });
                }
            });
        });
    </script>

    <script src="../static/assets/dist/js/bootstrap.bundle.min.js"></script>
    <script src="../static/js/sidebars.js"></script>

</body>

</html>